package com.caocaog.market.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.jeecg.common.system.base.entity.AllEntity;
import org.jeecg.common.system.base.entity.groups.UpdateGroup;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.LinkedHashMap;

/**
 * 推送消息模版管理
 *
 * @author chechen
 * @date 2022-05-21
 */
@Data
@NoArgsConstructor
@TableName("mk_push_message_template")
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "mk_push_message_template对象", description = "推送消息模版管理")
public class PushMessageTemplate extends AllEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    @NotNull(message = "更新时，id不能为空", groups = {UpdateGroup.class})
    @ApiModelProperty("ID")
    private Integer id;

    /**
     * 消息标题（长度建议取最小集）
     * 小米：title长度限制为50字
     * 华为：title长度限制40字
     * 魅族：title长度限制32字
     * OPPO：title长度限制32字
     * VIVO：title长度限制40英文字符
     */
    @NotBlank(message = "消息标题不能为空")
    @ApiModelProperty(value = "消息标题", required = true)
    private String title;

    /**
     * 消息内容(长度建议取最小集)
     * 小米：content长度限制128字
     * 华为：content长度小于1024字
     * 魅族：content长度限制100字
     * OPPO：content长度限制200字
     * VIVO：content长度限制100个英文字符
     */
    @NotBlank(message = "消息内容不能为空")
    @ApiModelProperty(value = "消息内容", required = true)
    private String content;

    @ApiModelProperty(value = "备注", required = true)
    private String remark;

    private transient LinkedHashMap<String, Object> payload;

    public PushMessageTemplate putPayload(String key, Object value) {
        if (this.payload == null) this.payload = new LinkedHashMap<>();
        this.payload.put(key, value);
        return this;
    }

}
